﻿using System;
using Interfaces.Add_Interfaces;
using Presenters.Inherited_Presenters;
using System.Windows.Forms;

namespace Presenters.Add_Presenters
{
    public class DocumentAddPresenter:OperationStatus
    {
        private IDocumentAddView view = null;
        private string selectedPath = null;
        private byte[] bytes = null;

        public DocumentAddPresenter(IDocumentAddView view)
        {
            this.view = view;
            Configure();
        }

        private void Configure()
        {
            view.Browser += GetDocument;
            view.Browser += UpdatePath;
            view.Save += ConvertDocument;
            view.Save += SaveDocument;
        }

        private void UpdatePath(object sender, EventArgs args)
        {
            if (selectedPath != null || selectedPath != String.Empty)
                view.pathDocument = selectedPath;
        }

        private void GetDocument(object sender, EventArgs args)
        {
            OpenFileDialog openFile = new OpenFileDialog();
            openFile.ShowDialog();
            selectedPath = openFile.FileName;
        }

        private void ConvertDocument(object sender, EventArgs args)
        {
            bytes = System.IO.File.ReadAllBytes(selectedPath);
        }

        private void SaveDocument(object sender, EventArgs args)
        {
        }
    }
}
